/*
* 表单提交验证
* */
var urlUAA="";

var AddUrl="/AddRecharGeruleServlet";
var UpdateUrl="/UpdateRecharGeruleServlet";


// 设置模态框 监听事件
$("#myModal").on('hide.bs.modal', function () {

})




function addrechargerule() {

    $("#myModalLabel").text("添加充值规则");
    // 调用显示模态框
    $("#myModal").modal('show');
    $("#rechargeruleForm")[0].reset();
    urlUAA= AddUrl;



}



function updaterechargerule(row) {

    $("#myModalLabel").text("修改充值规则");
    $("#coefficient").val(row.coefficient);
    $("#id").val(row.id);
    $("#status").val(row.status);
    $("#endTime").val(row.endTime);
    $("#startMoney").val(row.startMoney);
    $("#createdTime").val(row.createdTime);
    $("#name").val(row.name);


    urlUAA= UpdateUrl;
    // 调用显示模态框
    $("#myModal").modal('show');

}


function aaa (){
    // 当点击提交校验输入框

    var bootstrapValidator = $("#rechargeruleForm").data('bootstrapValidator');
     bootstrapValidator.validate();
    if (bootstrapValidator.isValid()){
        toastr['success']("校验成功");
        $.ajax({
            url:urlUAA,
            type:'post',
            data:$("#rechargeruleForm").serialize(),
            dataType:'json',
            success:function (result) {
                if (result.status > 0) {
                    toastr['success']("操作成功");
                    $("#myModal").modal('hide');
                    $("#rechargeruleList").bootstrapTable('refresh');
                } else {
                    toastr['error']("操作失败");
                }
            }
        })
    }else {
        toastr['error']("校验失败");



        // $("#oderForm")[0].reset();

    }
}

/**
 * 关闭模态框
 */
$("#myModal").on('hide.bs.modal', function () {
    //移除上次的校验配置
    $("#rechargeruleForm").data('bootstrapValidator').resetForm();
    $("#rechargeruleForm")[0].reset();
})

/*
* 初始化表单验证
* */
$("#rechargeruleForm").bootstrapValidator({
    feedbackIcons: {
        valid: 'glyphicon glyphicon-ok',
        invalid: 'glyphicon glyphicon-remove',
        validating: 'glyphicon glyphicon-refresh'
    },
    fields: {
        name: {
            validators: {
                notEmpty: {
                    message: "充值规则不能为空"
                }
            }
        },
        coefficient: {
            validators: {
                notEmpty: {
                    message: "充值系数不能为空"
                }
            }
        },
        status: {
            validators: {
                notEmpty: {
                    message: "状态不能为空"
                }
            }

        },
        createdTime: {
            validators: {
                notEmpty: {
                    message: "开始时间不能为空"
                }
            }

        },
        endTime: {
            validators: {
                notEmpty: {
                    message: "结束时间不能为空"
                }
            }

        },startMoney: {
            validators: {
                notEmpty: {
                    message: "起充金额不能为空"
                }
            }

        }
    }

});
